package com.cms.common.model.vo;

import com.cms.common.model.criteria.Criteria;
import com.cms.common.model.criteria.Restrictions;
import com.cms.common.model.entity.BaseEntity;
import lombok.Data;

import java.util.Map;

@Data
public class RequestData extends BaseEntity {
    private int page = 1;
    private int pageSize = 15;

    private Map<String, Object> objParams = null;
    private Map<String, Object> params = null;

    public void setObjParams(Criteria criteria) {
        Map<String, Object> objParams = this.getObjParams();
        if (objParams != null) {
            for (Map.Entry<String, Object> entry : objParams.entrySet()) {
                if (entry.getValue() != null) {
                    criteria.add(Restrictions.eq(entry.getKey(), entry.getValue()));
                }
            }
        }
    }
}
